const { defineConfig } = require('@vue/cli-service')
// 配置别名
const path = require('path');

console.log(process.env);


function resolve (dir) {
    return path.resolve(dir)
}
module.exports = defineConfig({
// 构建项目必须加这个属性
  publicPath:'.',

  lintOnSave: true,
    chainWebpack: (config)=>{
        config.resolve.alias
            .set('&', resolve('src'))
            .set('assets',resolve('src/assets'))
            .set('components',resolve('src/components'))
            .set('layout',resolve('src/layout'))
            .set('base',resolve('src/base'))
            .set('static',resolve('src/static'))


             //设置打包hash
              config.output
              .filename(
                `assets/js/[name].${process.env.VUE_APP_VERSION}.${+new Date()}.js`
              )
              .chunkFilename(
                `assets/js/[name].${process.env.VUE_APP_VERSION}.${+new Date()}.js`
              ) 
              .end();
    },

  transpileDependencies: true,
  lintOnSave: false,
  devServer:{
    port:parseInt(process.env.VUE_APP_PORT),  
    proxy:{
      "/api":{
        target:process.env.VUE_APP_BASE_URL,
        pathRewrite:{
          "^/api":""
        }
      }
    }
  }
})
